<?php
include_once './inc/config_inc.php';
include_once './inc/mysql_inc.php';
include_once './inc/tool_inc.php';
include_once './inc/page_inc.php';
$link=connect();
$user_id=is_login($link);
$is_manage_login=is_manage_login($link);//验证是否是后台管理员
if(!isset($_GET['id']) || !is_numeric($_GET['id'])){
	skip('index.php', 'error', '会员id参数不合法!');exit();
}
$query="select * from user where id={$_GET['id']}";
$result_user=execute($link, $query);
if(mysqli_num_rows($result_user)!=1){
	skip('index.php', 'error', '你所访问的会员不存在!');exit();
}
$data_user=mysqli_fetch_assoc($result_user);
$query="select count(*) from content where user_id={$_GET['id']}";
$count_all=num($link, $query);


$template['title']='用户中心';
$template['css']=array('style/public.css','style/user.css','style/word.css');
?>

<?php include 'inc/header_inc.php';?>

<!--用户中心-->
<div id="user">

	<div class="usr"><a href="index.php" style="font-size: 17px;font-family: 微软雅黑;color: black;margin-bottom: 20px;">首页</a> &gt; 
		<span style="font-size: 17px;font-family: 微软雅黑;margin-bottom: 20px;">用户中心</span></div>

	<div id="left">
		<div class="pages">
			<?php 
			$page=page($count_all,5);
			echo $page['html'];
			?>
		</div>
		<?php 
		
		$query="select content.id,content.create_time time,content.user_id,user.photo,user.name,content.times,content.content from content,user where content.user_id={$_GET['id']} and content.user_id=user.id order by content.create_time desc {$page['limit']}";
		$result=execute($link,$query);
		while($data=mysqli_fetch_assoc($result)){
			$data['content']=htmlspecialchars($data['content']);
		?>
		<div class="le"><img src="<?php if($data['photo']!=''){echo $data['photo'];}else{echo 'style/11.jpg';}?>"></div>
		<div class="ft">
			<p style="height: 60px;line-height:20px;"><?php echo $data['content']?></p>
			<p style="height: 20px;line-height: 20px;border-top: 0.5px solid white;">发布于:<?php echo $data['time']?>&nbsp;&nbsp;&nbsp;<?php echo $data['name']?>&nbsp;&nbsp;&nbsp;浏览：<?php echo $data['times']?>&nbsp;&nbsp;
			<?php 
				if(check_user($user_id,$data['user_id'],$is_manage_login)){
					$url=urlencode("content_delete.php?id={$data['id']}");
					$return_url=urlencode($_SERVER['REQUEST_URI']);
					$message="你真的要删除留言吗？";
					$delete_url="confirm.php?url={$url}&return_url={$return_url}&message={$message}";
					echo "<a href='content_update.php?id={$data['id']}'>编辑</a> <a href='{$delete_url}'>删除</a>";
				}
				?>
		</div>
		<?php } ?>	
			
	</div>
	

	<div id="right">
		<div class="shang"><img src="style/11.jpg"></div>
		<div class="xia">
			<p>用户名</p>
			<p>留言总计：</p>
			<p>操作：<a target="_blank" href="user_photo_update.php">修改头像</a> | <a target="_blank" href="user_pw_update.php">修改密码</a></p>
		</div>
	</div>
</div>


<?php include 'inc/footer_inc.php';?>